package com.atom.module.mvi.binder.lifecycle

import com.atom.module.mvi.binder.lifecycle.internal.FromObservableSource
import io.reactivex.rxjava3.core.ObservableSource

interface Lifecycle : ObservableSource<Lifecycle.Event> {

    enum class Event {
        BEGIN,
        END
    }

    companion object {

        /**
         * 创建一个可以发送event的事件源
         */
        fun manual(): ManualLifecycle =
            ManualLifecycle()

        /**
         * 将实现被监听对象为event的监听源包装类Lifecycle
         */
        fun wrap(source: ObservableSource<Event>) : Lifecycle =
            FromObservableSource(source)
    }

}
